How the Font Manager Renders TrueType Fonts
How the Font Manager Renders TrueType Fonts
TrueType fonts are stored as a collection of outline points. (Don't confuse
these outline points with the points that determine point size, or the Point data
type, which specifies a place on the QuickDraw coordinate plane.) The
Font Manager draws lines and curves between the points, sets the bits that
make the bitmap, and then displays the bitmap on the screen.
There are two types of outline points: on-curve points define the endpoints of
lines, and off-curve points determine the curve of the line between the
on-curve points. Two consecutive on-curve points define a straight line. If you
want to draw a curve, you need a third point that is off the curve and between
the two on-curve points.
F(t) = (1 - t)2 * A + 2t (1 - t) * B + t2 * C
where t ranges between 0 and 1 as the curve moves from point A to point C. A
and C are on-curve points; B is an off-curve point.
the following figure shows two Bézier curves. The positions of on-curve
points A and C remain constant, while off-curve point B shifts. The curve
changes in relation to the position of point B.
The effect of an off-curve point on two Bézier curves
A font designer can use any quantity of outline points to create a TrueType
outline. These points must be numbered in a logical order, because the
Font Manager draws lines and curves sequentially. This process produces a
glyph such as the lowercase “b” as shown below:
An outline with points on and off the curve
There are several groups of points in this figure that include two consecutive
off-curve points. For instance, points 2 and 3 are both off-curve. In this case,
the Font Manager places an on-curve point midway between the two
off-curve points, thereby defining two Bézier curves, as shown in the next
figure. Note that this additional on-curve point is for creation of the outline
glyph only; the Font Manager does not alter the 'sfnt' resource's list of
points.
A curve with consecutive off-curve points
When the Font Manager has completed drawing a closed loop, it has
completed one contour of the outline. The font designer groups the points in the
'sfnt' resource into contours. In the figure before last, the
Font Manager draws the first contour in the outline glyph from point 0 to
point 17, and the second contour from point 18 to the end, creating the glyph
in the following figure.
An outline glyph
At this stage, the outline glyph does not have a fixed point size. Remember that
point size is measured as the distance from the base line of one line of text to
the base line of the next line of single-spaced text. Because the
Font Manager has the measurements relative to the base line and ascent line
for the outline and the intended point size, it can correlate the two and
calculate how large the outline should be for that point size.
The Macintosh computer's display screen is a grid made of pixels. The
Font Manager fits the outline glyph, scaled for the correct size, to this grid.
If the center of one section of this grid-comparable to a pixel or a printer
dot-falls on a contour or within two contours, the Font Manager sets this bit
for the bitmap.
The Font Manager uses the contours as the boundaries for deciding which
bits make up the bitmap for this outline glyph when it is displayed. Because
there are two contours for the glyph in the last figure, the Font Manager
begins with pixels at the boundary marked by contour 1 and stops when it gets
to contour 2. Some glyphs need only one contour, such as the uppercase “I” in
some fonts. Others have three or more contours, such as the ›- glyph from ITC
Zapf Dingbats.
If the pixels are tiny in proportion to the outline (when resolution is high or
the point size of the glyph is large), they fill out the outline smoothly, and any
pixels that jut out from the contours are not noticeable. If the display device
has a lower resolution or the point size is small, the pixels are large in
relation to the outline. You can see in the next figure that the outline has
produced an unattractive bitmap because the centers of some pixels fall on the
wrong side of the contours, producing gaps and blocky areas that would not be
found in the high-resolution versions of the same glyph.
An unmodified outline glyph at a small point size
The pixels of the display device cannot change, so the outline should adapt in
order to produce a better bitmap. A font manufacturer must include
instructions in the 'sfnt' resource that indicate how to change the shape of the
outline under various conditions, such as low resolution or small point size.
The lowercase “b” outline in the next figure is the same one depicted in the
last picture, except that the Font Manager has applied the instructions to the
figure and produced a better bitmapped glyph. (These instructions are to the
effect of “move these points here” or “change the angle formed by these
points.” General-purpose applications do not need to use instructions;
however, if you want to know more about them, order the TrueType Font
Format Specification book from APDA.)
An instructed outline glyph
Once the Font Manager has produced the outline according to the design and
instructions, it turns on the pixels and draws the bitmap on the screen. It then
saves the bitmapped glyph in memory and uses it whenever the user requests
this glyph in this font at this point size.